package week05;
// import java.io.File;



//import java.io.BufferedReader;
//import java.io.FileReader;
//import java.io.FileWriter;
import java.io.*;
import java.util.Collections;
//import java.util.List;
import java.util.Vector;
//import java.util.Scanner;
import java.util.StringTokenizer;
//import java.util.logging.Level;
//import java.util.logging.Logger;

public class FileTokenTest2 {
   public static void main (String[] args)  throws FileNotFoundException
   {
   try {
       String strFile = "/home/depit/Desktop/lucian.txt";
      BufferedReader br = new BufferedReader( new FileReader(strFile));
      String strLine = "";
       StringTokenizer st = null;
       int lineNumber = 0, tokenNumber = 0;  
     
          //Scanner scan = new Scanner(new File("/home/depit/Desktop/lucian.txt"));

            while ((strLine = br.readLine()) != null) {
                lineNumber++;




                Vector<String> words = new Vector<String>();
              // String sentence = scan.nextLine();
                // default delimiter is " \t\n\r\f"
                String delimiter = " ,\t";
                StringTokenizer tokens = new StringTokenizer(",");
                System.out.printf("Number of elements: %d\n", tokens.countTokens());
                System.out.println("The tokens are:");
                st = new StringTokenizer(strLine, ",");
               while (st.hasMoreTokens()) {
                    //words.add(tokens.nextToken());

                   tokenNumber++;
                   System.out.println("Line # " + lineNumber +
                    ", Token # " + tokenNumber
                     + ", Token : "+ st.nextToken());




                  // System.out.println(tokens.nextToken());

                }
                 Collections.sort(words);
                System.out.println(words);
                // http://java.sun.com/docs/books/tutorial/collections/algorithms/index.html
    //for (List<String> l : words)
             //      System.out.println(l.size() + ": " + l);
           tokenNumber = 0;

            }
        } catch (Exception e) {
          

         
        }

   

   }
}
